package main

import (
	"github.com/zhang-jianqiang/user/config"
	"github.com/zhang-jianqiang/user/handler"
	pb "github.com/zhang-jianqiang/user/proto"
	"go-micro.dev/v4"
	"log"
)

var (
	service = "user"
	version = "latest"
)

func main() {
	// Create service
	srv := micro.NewService(
		micro.Name(service),
		micro.Version(version),
		micro.Registry(config.NewNacosRegistry().Register()),
		micro.Address(":8081"),
	)

	// Register handler
	err := pb.RegisterUserHandler(srv.Server(), new(handler.User))
	if err != nil {
		log.Fatalln(err)
	}
	srv.Init()

	// Run service
	if err := srv.Run(); err != nil {
		log.Fatal(err)
	}
}
